package com.xbongbong.saas.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

import java.util.Objects;

/**
 * @description:
 * @Author: hongxiao
 * @date: 2019-01-12 17:12
 */
@Getter
public enum SmsStatusEnum {
    /**
     * 短信状态
     */
    NO_SEND(0,"enum.smsStatus.name.no_send"),


    SEND_ING(1,"enum.smsStatus.name.send_ing"),


    SUCCESS_SEND(2,"enum.smsStatus.name.success_send"),


    FAILURE_SEND(3,"enum.smsStatus.name.failure_send"),


    CANCEL_SEND(4,"enum.smsStatus.name.cancel_send"),


    RE_SEND(5,"enum.smsStatus.name.re_send"),
    ;
    /**
     * 短信状态
     */
    private int code;
    /**
     * 短信状态名称
     */
    private String name;

    SmsStatusEnum(int code, String name) {
        this.code = code;
        this.name = name;
    }

    public static SmsStatusEnum getByCode(int code) {
        for (SmsStatusEnum cacheCode : values()) {
            if (cacheCode.getCode() == code) {
                return cacheCode;
            }
        }
        return null;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }
}
